
class Expression(object):
    def Evaluate(self):
        pass

class Number(Expression):
    value = 0

    def __init__(self, val):
        self.value = val

    def Evaluate(self):
        return self.value


class Unary(Expression):
    operation = ''
    subexpr = None

    def __init__(self, op, se):
        self.operation = op
        self.subexpr = se

    def Evaluate(self):
        exo = self.subexpr.Evaluate()
        if '-' == self.operation:
            exo = -exo
        return exo

class Binary(Expression):
    operation = ''
    first = None
    second = None

    def __init__(self, op, fi, se):
        self.operation = op
        self.first = fi
        self.second = se

    def Evaluate(self):
        exo = self.first.Evaluate()
        exi = self.second.Evaluate()
        if '+' == self.operation:
            return exo + exi
        if '-' == self.operation:
            return exo - exi
        if '*' == self.operation:
            return exo * exi
        if '/' == self.operation:
            return exo / exi
        return 0
